import { NextApiRequest, NextApiResponse } from "next";
import {
  getApp,
  getCurrentUser,
  getUserListOfApp,
  updateConfig,
} from "@/services";
import { App } from "@/entities/App";
import { User } from "@/entities/User";

// !!! this config is required
// export const config = {
//     api: {
//         bodyParser: false,
//     },
// };

async function changeStatus(req: NextApiRequest, res: NextApiResponse<APIRes>) {
  await updateConfig(req, res);
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  if (req.method === "POST") {
    changeStatus(req, res);
  } else {
    res.status(405).json({
      success: false,
      data: {},
      message: "Method not allowed",
    });
  }
}
